home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / HEX$.DMO < prev    next >
Text File  |  1996-07-04  |  5KB  |  113 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   HEX$    .DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $INCLUDE "DAS-NB01.INC"
  22. SHARED sMask$  : sMask$ = "##,###,###,### or "
  23.  
  24. COLOR 7, 0
  25. CLS
  26. ? "┌────────────────────────
  27. ? "│ fHEX$( Value&, Bytes? ) converts a decimal number into a hexadecimal
  28. ? "│                         expression that has been padded and formatted
  29. ? "│                         to the length you have requested.
  30. ? "│
  31. ? "│ fHEXval&( B$ )          converts DASoft's hexadecimal strings or standard
  32. ? "│                         hexadecimal strings back into decimal numbers.
  33. ? "├──────────────────────────────────────────────────────────────────────┘
  34. ? "│ fHEX$ creates hexadecimal strings that allow for easy viewing.
  35. ? "│ They can only be used, again, as numbers by fHEXval&.
  36. ? "│ These routines were used to enhance the printing of hexadecimal
  37. ? "│ expressions while programming. It really started out as a
  38. ? "│ programming tool but seems to have grown up a little!
  39. ? "└────────────────────────────────────────────────────────────────────────┘
  40.  
  41. LOCATE 16,  1 : PRINT "DASoft:"
  42. LOCATE 20,  1 : PRINT "PowerBASIC:"
  43. LOCATE 16, 50 : PRINT "<HOME> & <END>  +-    1"
  44. LOCATE 17, 50 : PRINT "<UP>   & <DOWN> +-  100"
  45. LOCATE 18, 50 : PRINT "<PgUp> & <PgDn> +- 1000"
  46. LOCATE 25, 50 : PRINT "PRESS <ESC> TO END";
  47.  
  48.                                                     '┌──────────────────────
  49. B? =  95                                            '│ assign some values
  50. I% =  56                                            '│ and create 3 strings
  51. L& = 65536                                          '│ of 1 byte, 2 bytes &
  52.                                                     '│ 4 bytes
  53. DO                                                  '│
  54.   DisplayB B?                                       '│ display the results
  55.   DisplayI I%                                       '│
  56.   DisplayL L&                                       '│
  57.   WHILE INSTAT : G$ = INKEY$ : WEND                 '│ clear the keyboard
  58.   WHILE NOT INSTAT : WEND                           '│ wait for a key press
  59.   SELECT CASE INKEY$                                '│ evaluate the key press
  60.     CASE CHR$(27)      : EXIT LOOP                  '│ <ESC> end program
  61.     CASE CHR$(000,071) : B? = MIN(   255, B? + 1)   '│ <HOME> incr B?
  62.     CASE CHR$(000,079) : B? = MAX(     0, B? - 1)   '│ <END>  decr B?
  63.     CASE CHR$(000,072) : I% = MIN( 32767, I% + 100) '│ <UP>   incr I%
  64.     CASE CHR$(000,080) : I% = MAX(-32767, I% - 100) '│ <DOWN> decr I%
  65.     CASE CHR$(000,073) : INCR L&, 1000              '│ <PgUp> incr L&
  66.     CASE CHR$(000,081) : DECR L&, 1000              '│ <PgDn> decr L&
  67.   END SELECT                                        '│
  68. LOOP                                                '│
  69. '────────────────────────────────────────────────────┼──────────────────────
  70. CLS                                                 '│ end of program
  71. END                                                 '│
  72. '────────────────────────────────────────────────────┴──────────────────────
  73.  
  74. SUB DisplayB( BYVAL B? ) LOCAL PUBLIC
  75.   LOCAL B$
  76.  
  77.   LOCATE 16, 13
  78.     B$ = fHEX$( B?, 1 )
  79.     B? = fHEXvalB?( B$ )
  80.     PRINT USING sMask$; B?; : PRINT B$
  81.   LOCATE 20, 13
  82.     PRINT USING sMask$; B?;
  83.     PRINT HEX$( B? ); SPACE$(12)
  84.  
  85. END SUB
  86.  
  87. SUB DisplayI( BYVAL I% ) LOCAL PUBLIC
  88.   LOCAL I$
  89.  
  90.   LOCATE 17, 13
  91.     I$ = fHEX$( I%, 2 )
  92.     I% = fHEXvalI%( I$ )
  93.     PRINT USING sMask$; I%; : PRINT I$
  94.   LOCATE 21, 13
  95.     PRINT USING sMask$; I%;
  96.     PRINT HEX$( I% ); SPACE$(12)
  97.  
  98. END SUB
  99.  
  100. SUB DisplayL( BYVAL L& ) LOCAL PUBLIC
  101.   LOCAL L$
  102.  
  103.   LOCATE 18, 13
  104.     L$ = fHEX$( L&, 4 )
  105.     L& = fHEXvalL&( L$ )
  106.     PRINT USING sMask$; L&; : PRINT L$
  107.   LOCATE 22, 13
  108.     PRINT USING sMask$; L&;
  109.     PRINT HEX$( L& ); SPACE$(12)
  110.  
  111. END SUB
  112.  
  113.